﻿<src:OverlayWindow x:Class="GW2PAO.Views.ZoneCompletion.ZoneCompletionView"
        x:Name="ZoneListViewWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:src="clr-namespace:GW2PAO.Views"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
        xmlns:View="clr-namespace:GW2PAO.Views.ZoneCompletion"
        xmlns:huddled="http://schemas.huddledmasses.org/wpf"
        xmlns:converters="clr-namespace:GW2PAO.Style.Converters"
        xmlns:core="clr-namespace:GW2PAO.PresentationCore;assembly=GW2PAO.PresentationCore"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        mc:Ignorable="d"
        MinHeight="78" Height="250"
        MinWidth="225" MaxWidth="225" Width="225"
        WindowStyle="None" AllowsTransparency="true" Background="Transparent"
        ResizeMode="NoResize"
        Topmost="True"
        Closed="Window_Closed"
        TextOptions.TextFormattingMode="Display">

    <src:OverlayWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Style/ResourceLibrary.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <converters:EventStateConverter x:Key="StateConverter" />
            <BooleanToVisibilityConverter x:Key="BoolToVisibility" />

            <core:AutoRefreshCollectionViewSource Source="{Binding ZoneItems}" x:Key="zoneItemsView">
                <CollectionViewSource.SortDescriptions>
                    <scm:SortDescription PropertyName="DistanceFromPlayer" />
                </CollectionViewSource.SortDescriptions>
            </core:AutoRefreshCollectionViewSource>
        </ResourceDictionary>
    </src:OverlayWindow.Resources>

    <!--See code-behind for ViewModel details-->
    <Grid>

        <!--<Grid.Effect>
            <DropShadowEffect Color="Black" BlurRadius="10" Opacity="0.5" Direction="0" ShadowDepth="0" />
        </Grid.Effect>-->

        <Grid.Background>
            <RadialGradientBrush Opacity="0.5" Center="0,0" GradientOrigin="0,0" RadiusX="1" RadiusY="1">
                <GradientStop Color="#FF5B4411" Offset="0"/>
                <GradientStop Color="#015B4411" Offset="1"/>
            </RadialGradientBrush>
        </Grid.Background>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Border Name="TitleBar" Style="{StaticResource TitleBarStyle}"
                MouseLeftButtonDown="TitleBar_MouseLeftButtonDown"
                Grid.Row="0">
            <Grid Margin="5,0,0,0">

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="35" />
                    <ColumnDefinition Width="35" />
                </Grid.ColumnDefinitions>

                <Image Name="TitleImage"
                       Grid.Column="0"
                       VerticalAlignment="Center"
                       Height="30" Width="30"
                       Margin="0,0,0,0"
                       Source="/Resources/zone.png"
                       MouseDown="TitleImage_MouseDown">
                    <Image.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Reset Unlocks">
                                <MenuItem Header="Current Zone" Command="{Binding ResetZoneUnlocksCommand}" />
                                <MenuItem Header="Global" Command="{Binding ResetAllUnlocksCommand}" />
                            </MenuItem>
                            <MenuItem Header="Reset Hidden Points">
                                <MenuItem Header="Current Zone" Command="{Binding ResetZoneHiddenCommand}" />
                                <MenuItem Header="Global" Command="{Binding ResetAllHiddenCommand}" />
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="Distance Units">
                                <MenuItem Header="Feet" IsCheckable="True" IsChecked="{Binding IsFeetSelected}" />
                                <MenuItem Header="Meters" IsCheckable="True" IsChecked="{Binding IsMetersSelected}" />
                                <MenuItem Header="Time-Distances" IsCheckable="True" IsChecked="{Binding IsTimeDistanceSelected}" />
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="Automatic Unlock">
                                <MenuItem Header="Waypoints" IsCheckable="True" IsChecked="{Binding UserSettings.AutoUnlockWaypoints}" />
                                <MenuItem Header="POIs" IsCheckable="True" IsChecked="{Binding UserSettings.AutoUnlockPois}" />
                                <MenuItem Header="Vistas" IsCheckable="True" IsChecked="{Binding UserSettings.AutoUnlockVistas}" />
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="Show Unlocked Zone Points" IsCheckable="True" IsChecked="{Binding UserSettings.ShowUnlockedPoints}" />
                            <MenuItem Header="Show">
                                <MenuItem Header="Show All" Command="{Binding ShowAllCommand}" />
                                <MenuItem Header="Show None" Command="{Binding ShowNoneCommand}" />
                                <Separator />
                                <MenuItem Header="Waypoints" IsCheckable="True" IsChecked="{Binding UserSettings.AreWaypointsVisible}" />
                                <MenuItem Header="POIs" IsCheckable="True" IsChecked="{Binding UserSettings.ArePoisVisible}" />
                                <MenuItem Header="Heart Quests" IsCheckable="True" IsChecked="{Binding UserSettings.AreHeartsVisible}" />
                                <MenuItem Header="Vistas" IsCheckable="True" IsChecked="{Binding UserSettings.AreVistasVisible}" />
                                <MenuItem Header="Skill Challenges" IsCheckable="True" IsChecked="{Binding UserSettings.AreSkillChallengesVisible}" />
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="Close" Click="CloseWindowButton_Click" />
                        </ContextMenu>
                    </Image.ContextMenu>
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Setter Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect ShadowDepth="0"
                                              Color="Goldenrod"
                                              Opacity="0"
                                              BlurRadius="25"/>
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="1"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:0.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>

                <Viewbox StretchDirection="DownOnly" Grid.Column="1" Margin="5,0,0,0" HorizontalAlignment="Left">
                    <core:OutlinedTextBlock VerticalAlignment="Center" 
                                            Fill="Orange"
                                            FontFamily="Candara" FontSize="17"
                                            Text="{Binding ZoneNameVM.ZoneName}" />
                </Viewbox>

                <Button Name="CollapseExpandButton"
                    Grid.Column="2"
                    Margin="5"
                    Click="CollapseExpandButton_Click">
                    <Button.Style>
                        <Style TargetType="Button" BasedOn="{StaticResource TitleBarButtonStyle}">
                            <Setter Property="Content" Value="{StaticResource CollapseGraphic}" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Visibility, ElementName=ItemsContainer}" Value="Collapsed">
                                    <DataTrigger.Setters>
                                        <Setter Property="Content" Value="{StaticResource ExpandGraphic}" />
                                    </DataTrigger.Setters>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>

                <Button Name="CloseWindowButton"
                    Grid.Column="3"
                    Margin="5"
                    Style="{StaticResource TitleBarButtonStyle}"
                    Content="{StaticResource CloseGraphic}"
                    Click="CloseWindowButton_Click" />
            </Grid>
        </Border>

        <Grid Name="ItemsContainer" Grid.Row="1">
            <ScrollViewer Style="{StaticResource LeftScrollViewer}"
                          HorizontalScrollBarVisibility="Hidden"
                          VerticalScrollBarVisibility="Auto">
                <StackPanel Width="{Binding ElementName=ItemsContainer, Path=ActualWidth}">

                    <ItemsControl Name="WorldEventsControl"
                                  ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                  ItemsSource="{Binding Source={StaticResource zoneItemsView}}">

                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <View:ZoneItemView DataContext="{Binding}"
                                                   Visibility="{Binding IsVisible, Converter={StaticResource BoolToVisibility}}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>

                    </ItemsControl>

                </StackPanel>
            </ScrollViewer>
        </Grid>

        <Grid Name="ResizeHeight" Grid.Row="2"
              Cursor="SizeNS"
              MouseLeftButtonDown="Resize_Init" MouseLeftButtonUp="Resize_End" MouseMove="Resizeing_Form">

            <Rectangle HorizontalAlignment="Stretch"
                       Height="3"
                       Fill="#01FFA500">
            </Rectangle>

            <Rectangle VerticalAlignment="Bottom"
                       HorizontalAlignment="Stretch"
                       Height="1">
                <Rectangle.Fill>
                    <LinearGradientBrush>
                        <GradientStop Color="#FFFFA500" Offset="0.5"/>
                        <GradientStop Color="#00FFA500" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
        </Grid>
    </Grid>
</src:OverlayWindow>
